<script setup>
	import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
	import { getConfig } from '@/api/system.js'
	import { useRefs, useWebConfigStore, useUserStore } from '@/stores'
	import { $tool, useStorage } from '@/utils'
	onLaunch((options) => {
		const { setWebConfig } = useWebConfigStore()
		const { get, set } = useStorage()
		getConfig().then(res => {
			setWebConfig(res.data)
		})

		const pid = options.query?.user_id;
		if (pid && !get('PID')) {
			set('PID', pid);
		}

		const scene = options.query?.scene;
		if (scene) {
			const sceneArr = decodeURIComponent(scene).split('&');
			const sceneObj = {};
			sceneArr.forEach(item => {
				const arr = item.split('=');
				sceneObj[arr[0]] = arr[1];
			})
			if (sceneObj.user_id) {
				set('PID', sceneObj.user_id);
			}
		}


		let token = options.query?.token;
		if (token) {
			const { setToken } = useUserStore()
			$tool.replaceUrlParam('token', '')
			setToken(token)
		}
	})
	onShow(() => {})
	onHide(() => {})
</script>

<style lang="scss">
	@import "static/y.scss";
	@import "static/iconfont.css";

	view {
		box-sizing: border-box;
	}

	page {
		background-color: #F6F8FB;
	}
</style>